/**
 * vip会员 会员卡相关接口
 *
 */
import request from '@/utils/request'
import Vue from 'vue'

/**
 * 会员卡相关接口
 */

// 获取所有会员卡
export function getAllVipCardList() {
  return request({
    url: '/memberAdmin/memberCategory/all',
    method: 'get'
  })
}

// 获取会员卡列表
export function getVipCardList() {
  return request({
    url: '/memberAdmin/memberCategory/list',
    method: 'get'
  })
}

// 启用或者暂停会员卡
export function changeVipCardStatus(data) {
  return request({
    url: '/memberAdmin/memberCategory/enable',
    method: 'post',
    params: data
  })
}

// 删除会员卡
export function delVipCard(id) {
  return request({
    url: '/memberAdmin/memberCategory/' + id,
    method: 'delete'
  })
}

// 根据Id获取会员卡信息
export function getVipCardDetailById(id) {
  return request({
    url: '/memberAdmin/memberCategory/info',
    method: 'get',
    params: { categoryId: id }
  })
}

// 新增编辑总提交
export function editVipCard(method, data) {
  return request({
    url: '/memberAdmin/memberCategory',
    method: method,
    data: data
  })
}

// step0 基础信息
export function getVipCardInfo(id) {
  return request({
    url: '/memberAdmin/memberCategory/basic',
    method: 'get',
    params: { categoryId: id }
  })
}

// step0 check名字是否重复
export function checkCardName(name) {
  return request({
    url: '/memberAdmin/memberCategory/checkName',
    method: 'get',
    params: { categoryName: name }
  })
}

// step1 开卡奖励
export function getCardReward(id) {
  return request({
    url: '/memberAdmin/memberCategory/award',
    method: 'get',
    params: { categoryId: id }
  })
}

// step2 开卡奖励
export function getCardRights(id) {
  return request({
    url: '/memberAdmin/memberCategory/rights',
    method: 'get',
    params: { categoryId: id }
  })
}

// step3 使用说明
export function getCardExplain(id) {
  return request({
    url: '/memberAdmin/memberCategory/explain',
    method: 'get',
    params: { categoryId: id }
  })
}

// step4 排序
export function editCardOrder(data) {
  return request({
    url: '/memberAdmin/memberCategory/order',
    method: 'post',
    data: data
  })
}

/**
 * 储值 相关
 *
 */

//  获取储值规则
export function getAccountRule() {
  return request({
    url: '/memberAdmin/memberAccount/accountRule',
    method: 'get'
  })
}

// 更新储值规则
export function updateAccountRule(data) {
  return request({
    url: '/memberAdmin/memberAccount/accountRule',
    method: 'put',
    data: data
  })
}

// 统一储值密码
export function setRechargePswOnly(password) {
  return request({
    url: '/memberAdmin/memberAccount/recharge_password',
    method: 'post',
    params: { password }
  })
}

/**
 * 会员信息相关
 *
 */

//  获取会员列表(废除)
// export function getVipList(params) {
//   return request({
//     url: '/memberAdmin/member/query',
//     method: 'get',
//     params: params
//   })
// }

// 获取会员列表
export function getVipList(data) {
  return request({
    url: '/memberAdmin/member/queryList',
    method: 'post',
    data: data
  })
}

// 获取会员列表
export function allMemberCount() {
  return request({
    url: '/memberAdmin/member/allMemberCount',
    method: 'get'
  })
}

//  根据id获取会员信息详情
export function getVipDetailById(params) {
  return request({
    url: '/memberAdmin/member/detail',
    method: 'get',
    params: params
  })
}

//  变更会员的个人信息
export function updateVipInfo(data) {
  return request({
    url: '/memberAdmin/member/data',
    method: 'put',
    data: data
  })
}

//  根据memberId 退会员的卡
export function cancelVipCardById(params) {
  return request({
    url: '/memberAdmin/member/cancelCard',
    method: 'post',
    params: params
  })
}

//  根据memberId 更换卡类型
export function changeVipCardType(params) {
  return request({
    url: '/memberAdmin/member/changeCategory',
    method: 'post',
    params: params
  })
}

//  根据memberId 赠送券
export function sendVipCoupon(data) {
  return request({
    url: '/memberAdmin/member/sendCoupon',
    method: 'post',
    data: data
  })
}

//  根据memberId 增加会员余额
export function addVipAccountBalance(data) {
  return request({
    url: '/memberAdmin/memberAccount/addBalance',
    method: 'post',
    data: data
  })
}

//  根据memberId 扣除会员余额
export function reduceVipAccountBalance(data) {
  return request({
    url: '/memberAdmin/memberAccount/reduceBalance',
    method: 'post',
    data: data
  })
}

// 获取会员资产信息
export function getVipAccountInfo(params) {
  return request({
    url: '/balancemanage/getBalanceAccountStats',
    method: 'get',
    params: params
  })
}
// 续费会员
export function renewMember(params) {
  return request({
    url: '/memberAdmin/member/renew',
    method: 'post',
    data: params
  })
}

/**
     * 赠送会员相关接口
     *
     */

//  获取赠送规则
export function getGiveVipCardRule() {
  return request({
    url: '/memberAdmin/giveMember/rule',
    method: 'get'
  })
}

//  更新赠送规则
export function updateGiveVipCardRule(data) {
  return request({
    url: '/memberAdmin/giveMember/rule',
    method: 'put',
    data: data
  })
}

//  生成一条赠送二维码记录
export function setGiveVipCardRecord(data) {
  return request({
    url: '/memberAdmin/giveMember/record',
    method: 'post',
    data: data
  })
}

// 获取赠送记录列表
export function getGiveVipCardRecordList(params) {
  return request({
    url: '/memberAdmin/giveMember/records',
    method: 'get',
    params: params
  })
}

// 根据code查询赠送详情
export function getGiveVipCardRecordDetail(data) {
  return request({
    url: '/memberAdmin/giveMember/record',
    method: 'get',
    params: { code: data }
  })
}

//  取消一条赠送记录
export function cancelGiveVipCardRecord(id) {
  return request({
    url: '/memberAdmin/giveMember/cancel',
    method: 'post',
    params: { giveRecordId: id }
  })
}

/**
     * 推广相关接口
     *
     */

//  获取推广拉新配置

export function getVipInviteConfig() {
  return request({
    url: '/memberAdmin/inviteMember/inviteConfig',
    method: 'get'
  })
}

//  更新推广拉新规则
export function updateVipInviteConfig(data) {
  return request({
    url: '/memberAdmin/inviteMember/inviteConfig',
    method: 'put',
    data: data
  })
}

// 获取会员推广记录
export function getVipInviteRecords(params) {
  return request({
    url: '/memberAdmin/inviteMember/inviteRecords',
    method: 'get',
    params: params
  })
}

/**
     * 导入会员接口
     */
// 获取导入的数据
export function getVipImportList(params) {
  return request({
    url: '/memberAdmin/memberImport/list',
    method: 'get',
    params: params
  })
}

// 获取商家所有推广员
export function getAllPromoters() {
  return request({
    url: '/memberAdmin/inviteMember/promoters',
    method: 'get'
  })
}

// 单个录入会员
export function importVipOffLine(data) {
  return request({
    url: '/memberAdmin/memberImport/offlineMember',
    method: 'post',
    data: data
  })
}

// 获取会员录入绑定二维码
export function getImportVipBindQrCode(params) {
  return request({
    url: '/memberAdmin/memberImport/qrCode',
    method: 'get',
    params: params
  })
}

// 删除未绑定的数据
export function delVipImportNoBinded(params) {
  return request({
    url: '/memberAdmin/memberImport/remove?' + Vue.prototype.$qs.stringify(params, { indices: false }),
    method: 'delete'
  })
}

// 获取导入的任务列表
export function getVipImportTasks(params) {
  return request({
    url: '/memberAdmin/memberImport/tasks',
    method: 'get',
    params: params
  })
}

/**
     * 支付即会员
     */
// 获取支付即会员配置
export function getPaymentIsMemberConfig() {
  return request({
    url: '/memberAdmin/member/payMemberCardConfig',
    method: 'get'
  })
}

// 保存支付即会员配置
export function savePaymentIsMemberConfig(data) {
  return request({
    url: '/memberAdmin/member/savePayMemberCardConfig',
    method: 'post',
    data: data
  })
}

/**
     * 会员批量操作
     */

/**
     * @method name...
     * @description 查询会员数量
     */
export function memberBatchJobMemberNum(data) {
  return request({
    url: '/memberAdmin/memberBatchJob/selectedNumber',
    method: 'post',
    data: data
  })
}

/**
     * @method memberBatchJob
     * @description 批量操作申请
     */
export function memberBatchJobForm(data) {
  return request({
    url: '/memberAdmin/memberBatchJob/batchJob',
    method: 'post',
    data: data
  })
}

/**
     * @method memberBatchJobList
     * @description 任务列表
     */
export function memberBatchJobList(params) {
  return request({
    url: '/memberAdmin/memberBatchJob/jobList',
    method: 'get',
    params: params
  })
}

/**
     * @method memberBatchJobFailList
     * @description 失败任务列表
     */
export function memberBatchJobFailList(params) {
  return request({
    url: '/memberAdmin/memberBatchJob/failDataList',
    method: 'get',
    params: params
  })
}

/**
     * @method getMemberCodeConfig
     * @description 会员码配置
     */
export function getMemberCodeConfig() {
  return request({
    url: '/memberAdmin/member/codeConfig',
    method: 'get'
  })
}

/**
     * @method saveMemberCodeConfig
     * @description 会员码配置
     */
export function saveMemberCodeConfig(params) {
  return request({
    url: '/memberAdmin/member/codeConfig',
    method: 'post',
    params: params
  })
}

/**
     * 实体卡操作
     */
/**
     * @method editEntityCardOps
     * @description 编辑实体卡
     * @param { Boolean } name...
     * @return { Boolean } name...
     */
export function editEntityCardOps(data) {
  return request({
    url: '/memberAdmin/member/entityCardOps',
    method: 'post',
    data: data
  })
}

// 会员标签操作
// 新增标签
export function addNewTag(data) {
  return request({
    url: '/memberAdmin/tags',
    method: 'post',
    data: data
  })
}
//  更新标签
export function editTag(data) {
  return request({
    url: '/memberAdmin/tags',
    method: 'put',
    data: data
  })
}
// 删除标签
export function delTag(id) {
  return request({
    url: '/memberAdmin/tags/' + id,
    method: 'delete'
  })
}
// 获取标签详情
export function getTagsDetail(params) {
  return request({
    url: '/memberAdmin/tags/detail',
    method: 'get',
    params: params
  })
}
// 获取会员标签历史
export function getTagsHistory(params) {
  return request({
    url: '/memberAdmin/tags/history',
    method: 'get',
    params: params
  })
}
// 新增标签组
export function addNewTagGroup(data) {
  return request({
    url: '/memberAdmin/tags/newTagGroup',
    method: 'post',
    data: data
  })
}
//  更新标签组
export function editTagGroup(data) {
  return request({
    url: '/memberAdmin/tags/group',
    method: 'put',
    data: data
  })
}
// 删除标签组
export function delTagGroup(id) {
  return request({
    url: '/memberAdmin/tags/group/' + id,
    method: 'delete'
  })
}
// 获取所有标签组
export function getTagsGroup(data) {
  return request({
    url: '/memberAdmin/tags/tagGroup',
    method: 'get',
    data: data
  })
}
// 获取商户下的标签列表
export function getTagsList(params) {
  return request({
    url: '/memberAdmin/tags/list',
    method: 'get',
    params: params
  })
}
// 新增 / 删除会员标签
export function setMemberTag(data) {
  return request({
    url: '/memberAdmin/tags/setMemberTag',
    method: 'post',
    data: data
  })
}
// 标记会员
export function tagMember(data) {
  return request({
    url: '/memberAdmin/tags/tagMember',
    method: 'post',
    data: data
  })
}

/* RFM */
// 获取会员分群列表
export function getMemberGroups(data) {
  return request({
    url: '/marketing/admin/memberGroup/getMemberGroups',
    method: 'get',
    data: data
  })
}
// 会员分群列表
export function selectMemberGroupConfigs(data) {
  return request({
    url: '/memberAdmin/memberGroup/selectMemberGroupConfigs',
    method: 'get',
    data: data
  })
}
// 会员分群配置
export function selectMemberGroups(data) {
  return request({
    url: '/memberAdmin/memberGroup/selectMemberGroups',
    method: 'get',
    data: data
  })
}
// 修改配置
export function updateMemberGroup(data) {
  return request({
    url: '/memberAdmin/memberGroup/updateMemberGroup',
    method: 'post',
    data: data
  })
}
// 开通状态 0:未开通 1:已开通 2:开通失败 3:欠费停用 4:关闭 -1:机构未开通插件
export function judgeOpenRfm(data) {
  return request({
    url: '/memberAdmin/memberGroup/judgeOpenRfm',
    method: 'get',
    data: data
  })
}
// 活动列表（分群）
export function groupList(data) {
  return request({
    url: '/marketing/admin/activity/list',
    method: 'get',
    data: data
  })
}


// 获取开卡权益
export function openCardBoon(data) {
  return request({
    url: '/memberAdmin/rights/getMenu',
    method: 'get',
    data: data
  })
}

// 获取商家所配置的开卡权益接口
export function openCardBoonList(data) {
  return request({
    url: '/memberAdmin/rights/getMenuByIdList?idList=' + data.idList,
    method: 'get',
    data: data
  })
}


